package com.ruoyi.project.mapper;

import java.math.BigDecimal;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.common.domainenum.FinSubjectDirectionType;
import com.ruoyi.project.domain.FinSubjectMonth;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * 科目余额Mapper接口
 *
 * @author abel
 * @date 2024-10-15
 */
public interface FinSubjectMonthMapper extends BaseMapper<FinSubjectMonth>
{

    /**
     * 查询科目余额列表
     *
     * @param finSubjectMonth 科目余额
     * @return 科目余额集合
     */
    List<FinSubjectMonth> selectFinSubjectMonthList(FinSubjectMonth finSubjectMonth);

    /**
     * 删除科目余额
     *
     * @param id 科目余额ID
     * @return 结果
     */
    public int deleteFinSubjectMonthById(Long id);

    /**
     * 批量删除科目余额
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    public int deleteFinSubjectMonthByIds(Long[] ids);

    @Select("select * from  fin_subject_month where package_id=#{packageId} and subject_id=#{subjectId} and year_value=#{year} and month_value=#{month}")
    FinSubjectMonth findByInfo(@Param("packageId") Long packageId,@Param("subjectId") Long subjectId, @Param("year")int year, @Param("month")int month);

    @Select("select * from  fin_subject_month where package_id=#{packageId} and subject_code=#{subjectCode} and year_value=#{year} and month_value=#{month}")
    FinSubjectMonth findByInfoCode(@Param("packageId") Long packageId,@Param("subjectCode") String subjectCode, @Param("year")int year, @Param("month")int month);

    @Update("update  fin_subject_month set subject_code=#{subjectCode} , subject_name=#{subjectName} , direction_type=#{directionType}" +
            " ,subject_level=#{subjectLevel} where subject_id=#{subjectId}")
    int updateBySubjectId(@Param("subjectId") Long subjectId, @Param("subjectCode")String subjectCode,
                           @Param("subjectName")String subjectName,@Param("directionType") FinSubjectDirectionType directionType, @Param("subjectLevel")Integer subjectLevel);

    @Update("update fin_subject_month set subject_level=#{subjectLevel} where subject_id=#{subjectId}")
    int updateLevelBySubjectId(@Param("subjectId") Long id, @Param("subjectLevel")Integer subjectLevel);
}
